#include <stdio.h>

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        char a;
        double b;
        scanf(" %c %lf", &a, &b);
        if (a == 'M') {
            printf("%.2f\n", b / 1.09);
        } else if (a == 'F') {
            printf("%.2f\n", b * 1.09);
        }
    }
    return 0;
}
